<?php
  require_once($_SERVER['DOCUMENT_ROOT']."/whmcs/dbconnect.php");
  function getBrowser()
  {
    $u_agent = $_SERVER['HTTP_USER_AGENT'];
    $bname = 'Unknown';
    if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent))
    {
      $bname = 'Internet Explorer';
      $ub = "MSIE";
    }
    elseif(preg_match('/Firefox/i',$u_agent))
    {
      $bname = 'Mozilla Firefox';
      $ub = "Firefox";
    }
    elseif(preg_match('/Chrome/i',$u_agent))
    {
      $bname = 'Google Chrome';
      $ub = "Chrome";
    }
    elseif(preg_match('/Safari/i',$u_agent))
    {
      $bname = 'Apple Safari';
      $ub = "Safari";
    }
    elseif(preg_match('/Opera/i',$u_agent))
    {
      $bname = 'Opera';
      $ub = "Opera";
    }
    elseif(preg_match('/Netscape/i',$u_agent))
    {
      $bname = 'Netscape';
      $ub = "Netscape";
    }
    return $bname;
  }
  
  $getBrowser = getBrowser();
  $path = "http://".$_SERVER['HTTP_HOST']."/whmcs/modules/admin/ticket_alert/";
  $str_query = "SELECT * FROM tbltickets
               WHERE adminunread != '0'";
  $result = mysql_query($str_query);
  $total_records = mysql_num_rows($result);  
  if ($total_records > 0)
  {
    echo "<table>";
    echo   "<tr>";
    echo   "<td bgcolor='#efefef'>Date Submitted</td>";
    echo   "<td bgcolor='#efefef'>Subject</td>";
    echo   "<td bgcolor='#efefef'>Submitter</td>";
    echo   "<td bgcolor='#efefef'>Status</td>";
    echo   "<td bgcolor='#efefef'>Last Reply</td>";
    echo   "</tr>";
    while($record = mysql_fetch_array($result))
    {
      echo "<tr>";
      echo "<td>". $record["date"]. "</td>";
      echo "<td>#". $record["tid"]. "-". $record["title"]. "</td>";
      echo "<td>". $record["name"]. "</td>";
      echo "<td>". $record["status"]. "</td>";
      echo "<td>". $record["lastreply"]. "</td>";
      echo "</tr>";
    }
    echo "</table>";
    if ($getBrowser == "Internet Explorer")
    {
      echo "<bgsound src='". $path_sound. "/phone.mid' />";
    }
    else
    {
      echo "<audio controls = 'controls' autoplay = 'true' hidden = 'true'><source src='". $path. "/phone.wav' type='audio/wav'/></audio>";
    }
  }
?>